package com.drop.entity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * User entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "user", catalog = "feature_mall")
public class User implements java.io.Serializable {

	// Fields

	private Integer userId;
	private String idCardNo;
	private String userName;
	private String password;
	private String tel;
	private String headImg;
	private String name;
	private String province;
	private String city;
	private String street;
	private Set<Cart> carts = new HashSet<Cart>(0);
	private Set<Shipaddress> shipaddresses = new HashSet<Shipaddress>(0);
	private Set<Collection> collections = new HashSet<Collection>(0);
	private Set<Order> orders = new HashSet<Order>(0);
	private Set<Comment> comments = new HashSet<Comment>(0);
	private Set<Shop> shops = new HashSet<Shop>(0);

	// Constructors

	/** default constructor */
	public User() {
	}

	public User(int userId) {
		this.userId = userId;
	}

	public User(String userName, String password, String tel) {
		this.userName = userName;
		this.password = password;
		this.tel = tel;
	}

	/** full constructor */
	public User(String idCardNo, String userName, String password, String tel,
			String headImg, String name,String province, String city,String street, Set<Cart> carts,
			Set<Shipaddress> shipaddresses, Set<Collection> collections,
			Set<Order> orders, Set<Comment> comments, Set<Shop> shops) {
		this.idCardNo = idCardNo;
		this.userName = userName;
		this.password = password;
		this.tel = tel;
		this.headImg = headImg;
		this.name = name;
		this.city = city;
		this.province = province;
		this.street = street;
		this.carts = carts;
		this.shipaddresses = shipaddresses;
		this.collections = collections;
		this.orders = orders;
		this.comments = comments;
		this.shops = shops;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "userId", unique = true, nullable = false)
	public Integer getUserId() {
		return this.userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	@Column(name = "idCardNo", length = 45)
	public String getIdCardNo() {
		return this.idCardNo;
	}

	public void setIdCardNo(String idCardNo) {
		this.idCardNo = idCardNo;
	}

	@Column(name = "userName", length = 45)
	public String getUserName() {
		return this.userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Column(name = "password", length = 45)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "tel", length = 45)
	public String getTel() {
		return this.tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	@Column(name = "headImg", length = 45)
	public String getHeadImg() {
		return this.headImg;
	}

	public void setHeadImg(String headImg) {
		this.headImg = headImg;
	}

	@Column(name = "name", length = 45)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Cart> getCarts() {
		return this.carts;
	}

	public void setCarts(Set<Cart> carts) {
		this.carts = carts;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Shipaddress> getShipaddresses() {
		return this.shipaddresses;
	}

	public void setShipaddresses(Set<Shipaddress> shipaddresses) {
		this.shipaddresses = shipaddresses;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Collection> getCollections() {
		return this.collections;
	}

	public void setCollections(Set<Collection> collections) {
		this.collections = collections;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Order> getOrders() {
		return this.orders;
	}

	public void setOrders(Set<Order> orders) {
		this.orders = orders;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Comment> getComments() {
		return this.comments;
	}

	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Shop> getShops() {
		return this.shops;
	}

	public void setShops(Set<Shop> shops) {
		this.shops = shops;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	@Override
	public String toString() {
		return "User{" +
				"userId=" + userId +
				", idCardNo='" + idCardNo + '\'' +
				", userName='" + userName + '\'' +
				", password='" + password + '\'' +
				", tel='" + tel + '\'' +
				", headImg='" + headImg + '\'' +
				", name='" + name + '\'' +
				", province='" + province + '\'' +
				", city='" + city + '\'' +
				", street='" + street + '\'' +
				'}';
	}
}